@extends("public.main")
@section("content")
    <div style="margin-left:200px;">
        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>用户管理 <span class="c-gray en">&gt;</span> 用户列表</nav>
        <div class="page-container">
            <div class="mt-20">
                <table class="table table-border table-bordered table-bg table-hover table-sort">
                    <thead>
                    <tr class="text-c">
                        <th width="40">ID</th>
                        <th width="40">昵称</th>
                        <th width="60">真实姓名</th>
                        <th width="40">角色</th>
                        <th width="80">学校</th>
                        <th width="80">学院</th>
                        <th width="80">学号</th>
                        <th width="80">宿舍</th>
                        <th width="80">联系方式</th>
                        <th width="80">是否会员</th>
                        <th width="80">到期时间</th>
                        <th width="40">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @if(!empty($data['data']))
                        @foreach($data['data'] as $k => $v)
                            <tr class="text-c va-m">
                                <td>{{ $v['id'] }}</td>
                                <td>{{ $v['nikename'] }}</td>
                                <td>{{ $v['name'] }}</td>
                                <td>@if($v['role']==0)学生 @else 教师@endif</td>
                                <td>{{ $v['school'] }}</td>
                                <td>{{ $v['college'] }}</td>
                                <td>{{ $v['student_num'] }}</td>
                                <td>{{ $v['dormitory'] }}</td>
                                <td>{{ $v['mobile'] }}</td>
                                <td>@if($v['is_member']==0) 非会员 @else 会员  @endif</td>
                                <td>@if($v['is_member']==0) 暂无 @else {{date('Y-m-d', $v['member_stop_time'])}}@endif</td>
                                <td class="td-manage"><a style="text-decoration:none" class="ml-5" href="/admin/user/edit/{{$v['id']}}" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> <a style="text-decoration:none" class="ml-5"  onclick="deletearticle(this,{{$v['id'] }})" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
                            </tr>
                        @endforeach
                    @else
                        <tr class="text-c va-m">暂无数据</tr>
                    @endif
                    </tbody>
                </table>
                <div id="pagelist" style="float:right;margin-top:10px">
                    {!! $data['data']->appends(['type' => $data['type']])->render() !!}
                </div>
            </div>
        </div>
    </div>
@endsection

<script>
    /*产品-删除*/
    function deletearticle(obj,id){
        var token = "{{csrf_token()}}";
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '/admin/user/del',
                data:{id:id,_token:token},
                dataType: 'json',
                success: function(data){
                    if(data.status == 200) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', {icon: 1, time: 1000});
                    } else {
                        layer.msg('删除失败!', {icon: 1, time: 1000});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }

</script>